using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MousRay : MonoBehaviour
{
    public Camera m_Camera;

    public Vector3 hitPosition;

    public bool isHit = false;
    private void MouseRayChack()
    {
        Ray ray = m_Camera.ScreenPointToRay(Input.mousePosition);

        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            Debug.DrawRay(ray.origin, hit.point);
        }

        GameObject gameObj = hit.collider.gameObject;
        if (gameObj.tag == ("Head"))
        {
            hitPosition = gameObj.transform.position;

            isHit = true;

        }
        else if (gameObj.tag == "Untagged")
            isHit = false;
        else if (gameObj.tag == "Null")
            isHit = false;
        //Debug.Log(isHit);
    }

    void Update()
    {
        MouseRayChack();
    }
}
